﻿<dxe:ComboBoxEdit x:Class="SBPweb.Sharepoint.Client.Controls.Users.UserTagEditor"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:localControls="clr-namespace:SBPweb.Sharepoint.Client.Controls.Users"
    xmlns:riaClientControls="clr-namespace:SBPweb.RIA.Client.Controls.Content;assembly=SBPweb.RIA.Client.Controls"
    xmlns:riaClientWindows="clr-namespace:SBPweb.RIA.Client.Controls.Windows;assembly=SBPweb.RIA.Client.Controls"
    xmlns:dxpfControls="clr-namespace:DevExpress.Xpf.Controls;assembly=DevExpress.Xpf.Controls.v10.2"
    xmlns:dxpfEditors="clr-namespace:DevExpress.Xpf.Editors;assembly=DevExpress.Xpf.Core.v10.2"
    xmlns:dxpfEditorControls="clr-namespace:DevExpress.Xpf.Editors.Controls;assembly=DevExpress.Xpf.Core.v10.2"
    xmlns:dxpfLookup="clr-namespace:DevExpress.Xpf.Grid.LookUp;assembly=DevExpress.Xpf.Grid.v10.2"
    xmlns:Custom="http://schemas.devexpress.com/winfx/2008/xaml/editors/internal"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    mc:Ignorable="d"
    d:DesignHeight="32" d:DesignWidth="120"
	ValueMember="LookupId" DisplayMember="LookupValue">
	<dxe:ComboBoxEdit.Resources>
        
        <!--<localControls:UserNameConverter x:Key="UserNameIdConverter" Attribute="LookupId" />
        <localControls:UserNameConverter x:Key="UserNameValueConverter" Attribute="LookupValue" />-->

        <Style x:Key="BaseTextBlockInplaceStyle" TargetType="TextBlock"/>
		<Style BasedOn="{StaticResource BaseTextBlockInplaceStyle}" x:Key="TextEditThemeKey_TextBlockInplaceStyle" TargetType="TextBlock">
			<Setter Property="Custom:EditorMarginHelper.Margin" Value="4,0,4,0,2,0,4,0" />
			<!--<Setter Property="Margin" Value="4,2,4,2"/>-->
			<!--<Setter Property="VerticalAlignment" Value="Center"/>-->
			<!--<Style.Triggers>
            <DataTrigger Binding="{Binding Path=HasValidationError, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type dxe:BaseEdit}}}" Value="True">
                <Setter Property="Margin" Value="2,2,4,2"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=ShowError, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type dxe:BaseEdit}}}" Value="false">
                <Setter Property="Margin" Value="4,2,2,2"/>
            </DataTrigger>

        </Style.Triggers>-->
		</Style>
        
		<ControlTemplate x:Key="UserTagEditDisplayTemplate">
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="32" />
					<ColumnDefinition />
				</Grid.ColumnDefinitions>
				<Image Grid.Column="0" />
				<TextBlock x:Name="PART_Editor" Grid.Column="1" Style="{StaticResource TextEditThemeKey_TextBlockInplaceStyle}" dx:FocusHelper2.Focusable="False" />
			</Grid>
		</ControlTemplate>
		<Custom:TextBoxPaddingConverter x:Key="TextEditTextBoxPaddingConverter" />
		<!--START Include: \..\..\..\..\Themes\LightGray\ScrollBar.xaml -->
		<Style x:Key="ScrollBarThemeKey_ScrollingCornerStyle" TargetType="Border">
			<Setter Property="Background" Value="#FFE9E9E9" />
		</Style>
		<ControlTemplate TargetType="ScrollViewer" x:Key="EditorListBoxThemeKey_ScrollViewerTemplate">
			<Grid x:Name="Grid" Background="{TemplateBinding Background}" UseLayoutRounding="True">
				<Grid.Resources>
					<Custom:ScrollContentPresenterMarginCorrector x:Key="ScrollContentPresenterMarginCorrector" />
				</Grid.Resources>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="*" />
					<ColumnDefinition Width="Auto" />
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="*" />
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>
				<ScrollContentPresenter Margin="{Binding Padding, Converter={StaticResource ScrollContentPresenterMarginCorrector}, RelativeSource={RelativeSource TemplatedParent}}" x:Name="ScrollContentPresenter" Grid.Column="0" Grid.Row="0" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanHorizontallyScroll="False" CanVerticallyScroll="False"/>
				<ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Cursor="Arrow" x:Name="VerticalScrollBar" Grid.Column="1" Grid.Row="0" ViewportSize="{TemplateBinding ViewportHeight}" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" AutomationProperties.AutomationId="VerticalScrollBar" />
				<ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Cursor="Arrow" x:Name="HorizontalScrollBar" Grid.Column="0" Grid.Row="1" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" AutomationProperties.AutomationId="HorizontalScrollBar" />
				<Border x:Name="Corner" Grid.Row="1" Grid.Column="1" Style="{StaticResource ScrollBarThemeKey_ScrollingCornerStyle}" />
			</Grid>
		</ControlTemplate>
		<!--PROCESS SETTERS WITH BINDING-->
		<Custom:HorizontalContentAlignmentToTextAlignmentConverter x:Key="HorizontalContentAlignmentToTextAlignmentConverter" />

        <Style x:Key="BaseTextInplaceStyle" TargetType="dxpfEditorControls:SLTextBox">
        
			<Setter Property="UseLayoutRounding" Value="True" />
			<Setter Property="VerticalAlignment" Value="Stretch" />
			<Setter Property="Template">
				<Setter.Value>

                    <ControlTemplate TargetType="dxpfEditorControls:SLTextBox">
                    
						<ScrollViewer x:Name="ContentElement" UseLayoutRounding="True" Padding="{Binding Padding, Converter={StaticResource TextEditTextBoxPaddingConverter}, RelativeSource={RelativeSource TemplatedParent}}" dx:FocusHelper2.Focusable="False" Template="{StaticResource EditorListBoxThemeKey_ScrollViewerTemplate}" Background="{TemplateBinding Background}" />
                    
					</ControlTemplate>
				</Setter.Value>
			</Setter>
        
        
			<Setter Property="Custom:ControlHelper.ClearDefaultStyleKey" Value="True" />
        
			<Setter Property="dx:DXStyleHelper.BindableSetters">
				<Setter.Value>
					<dx:DXBindableSetterCollection>
						<dx:DXBindableSetter Property="TextAlignment" Binding="{Binding (dxe:BaseEdit.OwnerEdit).HorizontalContentAlignment, Converter={StaticResource HorizontalContentAlignmentToTextAlignmentConverter}}"/>
						<dx:DXBindableSetter Property="MaxLength" Binding="{Binding (dxe:BaseEdit.OwnerEdit).MaxLength}"/>
						<dx:DXBindableSetter Property="Background" Binding="{Binding (dxe:BaseEdit.OwnerEdit).Background}"/>
						<dx:DXBindableSetter Property="Padding" Binding="{Binding (dxe:BaseEdit.OwnerEdit).Padding}"/>
						<dx:DXBindableSetter Property="IsTabStop" Binding="{Binding (dxe:BaseEdit.OwnerEdit).IsTabStop}"/>
						<dx:DXBindableSetter Property="IsReadOnly" Binding="{Binding (dxe:BaseEdit.OwnerEdit).IsReadOnly}"/>
						<dx:DXBindableSetter Property="AcceptsReturn" Binding="{Binding (dxe:BaseEdit.OwnerEdit).AcceptsReturn}"/>
						<dx:DXBindableSetter Property="TextWrapping" Binding="{Binding (dxe:BaseEdit.OwnerEdit).TextWrapping}"/>
						<dx:DXBindableSetter Property="VerticalContentAlignment" Binding="{Binding (dxe:BaseEdit.OwnerEdit).VerticalContentAlignment}"/>
						<dx:DXBindableSetter Property="VerticalScrollBarVisibility" Binding="{Binding (dxe:BaseEdit.OwnerEdit).VerticalScrollBarVisibility}"/>
						<dx:DXBindableSetter Property="HorizontalScrollBarVisibility" Binding="{Binding (dxe:BaseEdit.OwnerEdit).HorizontalScrollBarVisibility}"/>
						<dx:DXBindableSetter Property="VerticalAlignment2" Binding="{Binding (dxe:BaseEdit.OwnerEdit).VerticalContentAlignment}"/>
					</dx:DXBindableSetterCollection>
				</Setter.Value>
			</Setter>
		</Style>
        <Style BasedOn="{StaticResource BaseTextInplaceStyle}" x:Key="TextEditThemeKey_TextInplaceStyle" TargetType="dxpfEditorControls:SLTextBox">
			<Setter Property="BorderThickness" Value="0,0,0,0" />
			<Setter Property="BorderBrush" Value="{x:Null}" />
			<!--<Style.Triggers>
            <DataTrigger Binding="{Binding Path=HasValidationError, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type dxe:BaseEdit}}}" Value="True">
                <Setter Property="Margin" Value="0,2,2,2"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=ShowError, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type dxe:BaseEdit}}}" Value="false">
                <Setter Property="Margin" Value="2,2,2,2"/>
            </DataTrigger>

        </Style.Triggers>-->
	<!--<Setter Property="Margin" Value="2,2,2,2"/>--> 
			<Setter Property="VerticalAlignment" Value="Stretch" />
			<Setter Property="Custom:EditorMarginHelper.Margin" Value="2,0,2,0,0,0,2,0" />
		</Style>

        <ControlTemplate x:Key="UserTagEditInplaceTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="32" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Image Grid.Column="0" />
                <dxpfEditorControls:SLTextBox x:Name="PART_Editor" Grid.Column="1" Style="{StaticResource TextEditThemeKey_TextInplaceStyle}" IsReadOnly="True" />
            </Grid>
		</ControlTemplate>
          
    </dxe:ComboBoxEdit.Resources>
	<!--<dxe:ComboBoxEdit.DisplayTextConverter>
		<StaticResource ResourceKey="UserNameValueConverter" />
	</dxe:ComboBoxEdit.DisplayTextConverter>-->
    <dxe:ComboBoxEdit.EditInplaceTemplate>
        <StaticResource ResourceKey="UserTagEditInplaceTemplate" />
	</dxe:ComboBoxEdit.EditInplaceTemplate>
	<dxe:ComboBoxEdit.EditNonEditableInplaceTemplate>
        <StaticResource ResourceKey="UserTagEditInplaceTemplate" />
	</dxe:ComboBoxEdit.EditNonEditableInplaceTemplate>
	<dxe:ComboBoxEdit.DisplayTemplate>
		<StaticResource ResourceKey="UserTagEditDisplayTemplate" />
	</dxe:ComboBoxEdit.DisplayTemplate>

</dxe:ComboBoxEdit>